<?php
/**
 * Created by Mauro Gadaleta
 * User: Mauro
 * Date: 20/05/11
 * Time: 16:38
 */
class uagent_info {
    /**
     * @var string
     */
    var $useragent = "";

    /**
     * @var string
     */
    var $httpaccept = "";

    /**
     * @var array
     */
    var $mobileDevices = array(
        'iPhone',
        'iPad',
        'ipod',
        'Android',
        'SymbianOS',
        'IEMobile',
        'Mobile'
    );

    /**
     * Constructor set up
     * @return void
     */
    function uagent_info()
    {
       $this->useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
       $this->httpaccept = strtolower($_SERVER['HTTP_ACCEPT']);
    }

    /**
     * @return string
     */
    function Get_Uagent()
    {
       return $this->useragent;
    }

    /**
     * @return bool
     */
    function detectMobile()
    {
        foreach ($this->mobileDevices as $device)
        {
            if( stripos($this->useragent , $device) > -1 )
                return true;
        }
        return false;
    }
}
